<div id="content" style="background-color:#ffffff">
  <div id="content-header">
    <div id="breadcrumb"> <a href="?m=admin&t=main" title="Go to Home" class="tip-bottom"><i class="icon-home"></i> 后台首页</a> <a href="#">问题模块设置</a> <a href="#" class="current">门店用户</a> </div>
  </div>
  <div class="container-fluid">
    <div class="row-fluid">
        <fieldset class="layui-elem-field">
          <legend>门店用户</legend>
          <div class="layui-field-box">
         
            <form id="form-wizard" class="layui-form" method="post" action="?m=admin&o=questionsite&t=saveuser&id=<{$gvar.fget.id}>">
             
                 <div class="layui-form-item">
                    <label class="layui-form-label">用户名称</label>
                    <div class="layui-input-block">
                      <input type="text" name="name" value="<{$data.name}>" lay-verify="required" autocomplete="off" placeholder="请输入用户名称" class="layui-input">
                    </div>
                  </div>
				    <div class="layui-form-item">
                    <label class="layui-form-label">密码</label>
                    <div class="layui-input-block">
                      <input type="password" name="password" value="<{$data.password}>" lay-verify="required" autocomplete="off" placeholder="请输入密码" class="layui-input">
                    </div>
                  </div>
				  <{if $gvar.fget.id!=1}>
					  <div class="layui-form-item layui-form-text">
						  <label class="layui-form-label">省份</label>
						  <div class="layui-input-block">
							  <select name="province_id" id='province' lay-filter="province">
								 <option value='0'>选择省份</option>
								 <{foreach from=$provinceslist key=myId_2 item=menu_2}>
									<option value="<{$menu_2.id}>" <{if $menu_2.id==$data.province_id}>selected<{/if}>><{$menu_2.name}></option>
								 <{/foreach}>
							  </select>
						  </div>
						</div>
				  <{/if}>
				  <div class="layui-form-item layui-form-text">
					  <label class="layui-form-label">市</label>
					  <div class="layui-input-block">
						  <select name="city_id" id='city' lay-filter="city">
							 <option value='0'>选择市</option>
							 <{foreach from=$citylist key=myId_2 item=menu_2}>
								<option value="<{$menu_2.id}>" <{if $menu_2.id==$data.city_id}>selected<{/if}>><{$menu_2.name}></option>
							 <{/foreach}>
						  </select>
					  </div>
				 </div>
				 <div class="layui-form-item layui-form-text">
					  <label class="layui-form-label">县区</label>
					  <div class="layui-input-block">
						  <select name="country_id" id='country' lay-filter="country">
							 <option value='0'>选择县区</option>
							 <{foreach from=$countrylist key=myId_2 item=menu_2}>
								<option value="<{$menu_2.id}>" <{if $menu_2.id==$data.country_id}>selected<{/if}>><{$menu_2.name}></option>
							 <{/foreach}>
						  </select>
					  </div>
				 </div>
				 <div class="layui-form-item layui-form-text">
					  <label class="layui-form-label">门店</label>
					  <div class="layui-input-block">
						  <select name="shop_id" id='shop'>
							 <option value='0'>选择门店</option>
							 <{foreach from=$shoplist key=myId_2 item=menu_2}>
								<option value="<{$menu_2.id}>" <{if $menu_2.id==$data.shop_id}>selected<{/if}>><{$menu_2.name}></option>
							 <{/foreach}>
						  </select>
					  </div>
				 </div>
				 <!--<input type="hidden" name="role_id" value="<{$data.role_id}>" lay-verify="required" autocomplete="off"  class="layui-input">-->
				 <div class="layui-form-item layui-form-text">
					  <label class="layui-form-label">一级角色</label>
					  <div class="layui-input-block">
						  <select id='role_1' name='role_1' lay-filter="role_1">
							 <option value='0'>选择角色</option>
							 <{foreach from=$rolelist key=myId_2 item=menu_2}>
								<option value="<{$menu_2.id}>" <{if $menu_2.id==$data.role_1}>selected<{/if}>><{$menu_2.name}></option>
							 <{/foreach}>
						  </select>
					  </div>
				 </div>
				 <div class="layui-form-item layui-form-text">
					  <label class="layui-form-label">二级角色</label>
					  <div class="layui-input-block">
						  <select id='role_2' name='role_2' lay-filter="role_2">
							 <option value='0'>选择二级角色</option>
							 <{foreach from=$getTworole key=myId_2 item=menu_2}>
								<option value="<{$menu_2.id}>" <{if $menu_2.id==$data.role_2}>selected<{/if}>><{$menu_2.name}></option>
							 <{/foreach}>
						  </select>
					  </div>
				 </div>
                  <div class="layui-form-item layui-form-text">
                    <label class="layui-form-label">描述</label>
                    <div class="layui-input-block">
                      <textarea placeholder="请输入描述"  name="note" class="layui-textarea"><{$data.note}></textarea>
                    </div>
                  </div>
              <div class="layui-form-item">
                <div class="layui-input-block">
                  <button class="layui-btn" lay-submit="" lay-filter="demo1">立即提交</button>
                  
                 
                </div>
              </div>
            </form>
          </div>
        </fieldset>
</div>
<script>
layui.use(['form','tree','layer'], function(){
  var form = layui.form();
  var layer = layui.layer;
  form.on('select(province)', function(data){
	  var province = $('#province').val();
      $.ajax({
		   type: "POST",
		   url: "index.php?m=admin&o=questionsite&t=city",
		   dataType:"json",
		   data: {province:province},
		   success: function(msg){
			var msg = JSON.stringify(msg);
			msg = JSON.parse(msg);
			//console.log(aaa);
			var str = '';
			for (var key in msg){
				var str = str+"<option value='"+msg[key]['id']+"'>"+msg[key]['name']+"</option>";
			}
			$("#city").html("<option value='0' >选择市</option>");
			$("#city").append(str);
			$("#country").html("");
			$("#country").html("<option value='0' >选择县区</option>");
			$("#country").append(str);
			form.render();
			$.ajax({
				   type: "POST",
				   url: "index.php?m=admin&o=questionsite&t=getareashop",
				   dataType:"json",
				   data: {selectid:province,area:'province_id'},
				   success: function(msg){
					    var msg = JSON.stringify(msg);
						msg = JSON.parse(msg);
						//console.log(aaa);
						var strr = '';
						for (var key in msg){
							var strr = strr+"<option value='"+msg[key]['id']+"'>"+msg[key]['name']+"</option>";
						}
						$("#shop").html("<option value='0' >选择门店</option>");
						$("#shop").append(strr);
						form.render();
				   }
			});
		   }
		});
  });
    form.on('select(city)', function(data){
	  var city = $('#city').val();
      $.ajax({
		   type: "POST",
		   url: "index.php?m=admin&o=questionsite&t=country",
		   dataType:"json",
		   data: {city:city},
		   success: function(msg){
			var msg = JSON.stringify(msg);
			msg = JSON.parse(msg);
			//console.log(aaa);
			var str = '';
			for (var key in msg){
				var str = str+"<option value='"+msg[key]['id']+"'>"+msg[key]['name']+"</option>";
			}
			$("#country").html("<option value='0' >选择县区</option>");
			$("#country").append(str);
			form.render();
			$.ajax({
				   type: "POST",
				   url: "index.php?m=admin&o=questionsite&t=getareashop",
				   dataType:"json",
				   data: {selectid:province,area:'city_id'},
				   success: function(msg){
					    var msg = JSON.stringify(msg);
						msg = JSON.parse(msg);
						//console.log(aaa);
						var strr = '';
						for (var key in msg){
							var strr = strr+"<option value='"+msg[key]['id']+"'>"+msg[key]['name']+"</option>";
						}
						$("#shop").html("<option value='0' >选择门店</option>");
						$("#shop").append(strr);
						form.render();
				   }
			});
		   }
		});
  });
  form.on('select(country)', function(data){
		var country = $('#country').val();
		$.ajax({
				   type: "POST",
				   url: "index.php?m=admin&o=questionsite&t=getareashop",
				   dataType:"json",
				   data: {selectid:province,area:'country_id'},
				   success: function(msg){
					    var msg = JSON.stringify(msg);
						msg = JSON.parse(msg);
						//console.log(aaa);
						var strr = '';
						for (var key in msg){
							var strr = strr+"<option value='"+msg[key]['id']+"'>"+msg[key]['name']+"</option>";
						}
						$("#shop").html("<option value='0' >选择门店</option>");
						$("#shop").append(strr);
						form.render();
				   }
			});
  });
    form.on('select(role_1)', function(data){
		var role_1 = $('#role_1').val();
		$.ajax({
				   type: "POST",
				   url: "index.php?m=admin&o=questionsite&t=gettworole",
				   dataType:"json",
				   data: {id:role_1},
				   success: function(msg){
					    var msg = JSON.stringify(msg);
						msg = JSON.parse(msg);
						//console.log(aaa);
						var strr = '';
						for (var key in msg){
							var strr = strr+"<option value='"+msg[key]['id']+"'>"+msg[key]['name']+"</option>";
						}
						$("#role_2").html("<option value='0' >选择二级角色</option>");
						$("#role_2").append(strr);
						form.render();
				   }
			});
  })
});
 
</script>